# 打包依赖阶段使用golang作为基础镜像
FROM golang:1.20-alpine as builder

# 启用go module
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct

WORKDIR /app

COPY . .

RUN go mod download
# 指定OS等，并go build
RUN go build -o /build

# 运行阶段指定alpine作为基础镜像
FROM alpine

WORKDIR /app

COPY --from=builder /build /app/mysqld_exporter

# 指定运行时环境变量
ENV GIN_MODE=release \
    PORT=9104


EXPOSE 9104
ENV TZ=Asia/Shanghai
ENTRYPOINT ["./mysqld_exporter"]